<?php

/**
 * Product form base class.
 *
 * @method Product getObject() Returns the current form's model object
 *
 * @package    Bojss
 * @subpackage form
 * @author     Atu
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseProductForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                => new sfWidgetFormInputHidden(),
      'category_id'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Category'), 'add_empty' => false)),
      'manufacturer_id'   => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Manufacturer'), 'add_empty' => false)),
      'name'              => new sfWidgetFormInputText(),
      'type'              => new sfWidgetFormInputText(),
      'intro_description' => new sfWidgetFormTextarea(),
      'description'       => new sfWidgetFormTextarea(),
      'code'              => new sfWidgetFormInputText(),
      'price'             => new sfWidgetFormInputText(),
      'price_sale'        => new sfWidgetFormInputText(),
      'sale_begin'        => new sfWidgetFormDateTime(),
      'sale_end'          => new sfWidgetFormDateTime(),
      'product_date'      => new sfWidgetFormDate(),
      'is_active'         => new sfWidgetFormInputText(),
      'created_at'        => new sfWidgetFormDateTime(),
      'created_user_id'   => new sfWidgetFormInputText(),
      'updated_at'        => new sfWidgetFormDateTime(),
      'updated_user_id'   => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'id'                => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'category_id'       => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Category'))),
      'manufacturer_id'   => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Manufacturer'))),
      'name'              => new sfValidatorString(array('max_length' => 100)),
      'type'              => new sfValidatorInteger(),
      'intro_description' => new sfValidatorString(),
      'description'       => new sfValidatorString(),
      'code'              => new sfValidatorString(array('max_length' => 50)),
      'price'             => new sfValidatorNumber(array('required' => false)),
      'price_sale'        => new sfValidatorNumber(),
      'sale_begin'        => new sfValidatorDateTime(),
      'sale_end'          => new sfValidatorDateTime(),
      'product_date'      => new sfValidatorDate(),
      'is_active'         => new sfValidatorInteger(array('required' => false)),
      'created_at'        => new sfValidatorDateTime(),
      'created_user_id'   => new sfValidatorInteger(),
      'updated_at'        => new sfValidatorDateTime(),
      'updated_user_id'   => new sfValidatorInteger(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('product[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Product';
  }

}
